﻿
 
 var Page;
 var BaseUrl;
 
 function setBaseUrl(baseurl){
    
    BaseUrl = baseurl;
 }
 
 function setPageID(pageid)
 {
       Page = pageid;

 }
 
 
 function getPageID(){
 
    return Page;
 }
 
 function getBaseUrl(){
    return BaseUrl;
 }


function Initialize(texclientid, paremeters, font, editorcss){

  
    tinyMCE.init({
            mode: 'textareas',
            entity_encoding : 'utf-8',  
            elements: texclientid,  
            theme: 'advanced', 
            skin: 'o2k7',
            skin_variant: 'silver',
            convert_urls : false, 
            plugins:'style,safari,pagebreak,style,layer,table,advhr,advimage,advlink,emotions,spellchecker,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template', 
            theme_advanced_buttons1 : paremeters,
            theme_advanced_buttons2 : font,
            theme_advanced_buttons3 : "",
            theme_advanced_buttons4 : "",
            theme_advanced_toolbar_location : "top",
            theme_advanced_toolbar_align : "left",
            content_css : editorcss,
            file_browser_callback : 'MyBrowseSetting',
            remove_linebreaks : false, 
            extended_valid_elements : "textarea[cols|rows|disabled|name|readonly|class]" 
    });   
}




function MyBrowseSetting(field_name, url, type, win) {

  
   var basestring = getBaseUrl();
  var cmsURL = basestring+"TinyMCEAdapter/WrapServerObjectBrowser.aspx?id="+getPageID()+"&type="+type;
 
   tinyMCE.activeEditor.windowManager.open({
        file : cmsURL,
        title : 'EPiServer File Browser',
        width : 620,  
        height : 650,
        resizable : "yes",
        inline : "yes", 
        close_previous : "no"
    }, {
        window : win,
        input : field_name
    });
    
}

